<?php

$this->title = Yii::t('menu', 'Json Format');
$this->params['breadcrumbs'][] = $this->title;

?>
<div class="code-container">
    <div class="row">
        <div class="col-md-5">
            <textarea id="code-data" class="code-text code-textarea code-inset-shadow"></textarea>
        </div>
        <div id="code-method" class="col-md-2 text-center">
            <button method="copyRst" id="copyRst" type="button" class="btn btn-default" data-clipboard-target="#code-view">
                <?= Yii::t('code', 'Copy Result')?></button>
            <button method="jsonColorful" type="button" class="btn btn-default">
                <?= Yii::t('code', 'Json Format')?></button>
            <button method="md5" type="button" class="btn btn-default">
                <?= Yii::t('code', 'MD5')?></button>
            <button method="Base64encode" type="button" class="btn btn-default">
                <?= Yii::t('code', 'Base64encode')?></button>
            <button method="Base64decode" type="button" class="btn btn-default">
                <?= Yii::t('code', 'Base64decode')?></button>
        </div>
        <div class="col-md-5">
            <div id="code-view" class="code-text code-view code-inset-shadow"></div>
        </div>
    </div>
</div>
<?php
$this->registerJsFile('@web/static/js/clipboard.js',['depends' => 'app\assets\AppAsset']);
$this->registerJsFile('@web/static/js/color-json.js',['depends' => 'app\assets\AppAsset']);
$this->registerJsFile('@web/static/js/code.js',['depends' => 'app\assets\AppAsset']);

$successMsg = Yii::t('app', 'Copy Success');
$errorMsg = Yii::t('app', 'Copy Failed');
$js = <<<js
// 复制结果
new ClipboardJS('#copyRst').on('success', function(e) {
    layer.msg('{$successMsg}', {time: 3000, icon:6});
}).on('error', function(e) {
    layer.msg('{$successMsg}', {time: 5000, icon:5});
});

js;
$this->registerJs($js);
?>